package easier.window.dialog.bottom;

import android.content.Context;
import android.view.Gravity;
import android.view.ViewGroup.LayoutParams;
import android.view.Window;
import android.view.WindowManager;
import easier.window.dialog.BaseDialog;
import easier.window.window.R;

/**
 * 继承自{@link BaseDialog}
 * 1.style配置了动画从底部弹出
 * 2.配置了{@link WindowManager.LayoutParams#gravity}为{@link Gravity#BOTTOM}
 */
public class BottomDialog extends BaseDialog {

    public BottomDialog( Context context ) {

        /* 该样式决定从底部弹出 */
        super( context, R.style.bottom_dialog );
    }

    /**
     * @param window 用于个性化配置window
     */
    @Override
    protected void configWindow( Window window ) {

        /* gravity为BOTTOM */
        WindowManager.LayoutParams layoutParams = window.getAttributes();
        layoutParams.gravity = Gravity.BOTTOM;
        layoutParams.width = LayoutParams.MATCH_PARENT;

        window.setAttributes( layoutParams );
    }
}
